IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].SaveAttachmentWithNewName') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].SaveAttachmentWithNewName
GO

/***************************************************************************
* Name:				SaveAttachmentWithNewName
* Purpose:			Updates the name for the attachement.
*
* PARAMETERS
* Name				Description					
* -------------		-----------------------------------------------------------
* @attachmentId		id of the attachment
* @attachmentName    name of the attachment
***************************************************************************/

CREATE PROCEDURE dbo.SaveAttachmentWithNewName
(
	@attachmentId INT,	
	@attachmentName VARCHAR(255),
	@attachmentParentId INT
)
AS
BEGIN
	
	SET NOCOUNT ON

	UPDATE ProtocolDocument
	SET Name = @attachmentName,
	ParentDocumentId = @attachmentParentId
	WHERE Id = @attachmentId

END

GO
